﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SaunaServer.Model.Logger
{
    /// <summary>
    /// Logger Factory class
    /// </summary>
    /// <dates>
    /// 15/05/2011 - created by Chiaki Sato
    /// </dates>
    public class LoggerFactoryImplementation : ILoggerFactory
    {
        /// <summary>
        /// Make each logger class instance
        /// </summary>
        /// <param name="name">logger name</param>
        public ILogger Make(string name)
        {
            switch (name)
            {
                case "ConsoleLogger":
                    return new ConsoleLogger(ConsoleLogger.LogType.UNIT);

                case "FileLogger":
                    return new FileLogger(FileLogger.LogType.UNIT);

                // Mail logger for Blusteam Server
                case "MailLoggerForServer":
                    return new MailLogger(MailLogger.LogType.UNIT, MailLogger.ExeType.SERVER);

                // Mail logger for Blusteam Client
                case "MailLoggerForClient":
                    return new MailLogger(MailLogger.LogType.UNIT, MailLogger.ExeType.CLIENT);

                // XML logger
                case "XmlLogger":
                    return new XmlLogger(XmlLogger.LogType.UNIT);

                case "CompositeLogger":
                    CompositeLogger compoLogger = new CompositeLogger();
                    compoLogger.add(new FileLogger(FileLogger.LogType.COMPO));
                    compoLogger.add(new MailLogger(MailLogger.LogType.COMPO, MailLogger.ExeType.SERVER));
                    compoLogger.add(new XmlLogger(XmlLogger.LogType.COMPO));
                    return compoLogger;

                default:
                    throw new Exception(String.Format("ILoggerFactory can not create: {0}", name));
            }
        }
    }
}
